Java - What's the most efficient way of removing a set of elements from an Array[]
Posted
by fraido
on Stack Overflow
See other posts from Stack Overflow
or by fraido
Published on 2010-04-14T15:33:09Z
Indexed on
2010/04/14
16:43 UTC
Read the original article
Hit count: 200
I've something like this
Object[] myObjects = ...(initialized in some way)...
int[] elemToRemove = new int[]{3,4,6,8,...}
What's the most efficient way of removing the elements of index position 3,4,6,8... from myObjects ?
I'd like to implement an efficient Utility method with a signature like
public Object[] removeElements(Object[] object, int[] elementsToRemove) {...}
The Object[] that is returned should be a new Object of size myObjects.length - elemToRemove.length
© Stack Overflow or respective owner